module.exports = {
  productionSourceMap: false,
  transpileDependencies: ['uview-ui'],
  configureWebpack: { devServer: { disableHostCheck: true } },
  chainWebpack: config => {
    config.module.rule('vue').use('vue-loader').loader('vue-loader').tap(options => {
      const compile = options.compiler.compile
      options.compiler.compile = (template, ...args) => {
        if (args[0].resourcePath.match(/^pages/)) {
          template = template.replace(/[\s\S]+?<[\d\D]+?>/, _ => `${_}
		    <empowerDialog ref="showSheet" />
		  `)
        } else if (args[0].resourcePath.match(/^subpkg/)) {
          // 匹配到 subpkg 目录下的文件
          template = template.replace(/[\s\S]+?<[\d\D]+?>/, _ => `${_}
           <empowerDialog id="showSheet" ref="showSheet" />
        `)
        }
        return compile(template, ...args)
      }
      return options
    })
  }
}
